bool checkBrackets(const std::string& s) {
    std::stack<char> stack;
    std::unordered_map<char, char> symbols = {{')', '('}, {']', '['}, {'}', '{'}, {'>', '<'}};

    std::set<char> opening_symbols = {'(', '[', '{', '<'};
    std::set<char> closing_symbols = {')', ']', '}', '>'};

    for (char i : s) {
        if (opening_symbols.count(i) > 0) {
            stack.push(i);
        } else if (closing_symbols.count(i) > 0) {
            if (stack.empty()) {
                return false;
            }
            if (stack.top() != symbols[i]) {
                return false;
            }
            stack.pop();
        }
    }

    return stack.empty();
}

int main() {
    std::string SymbolsPrint;
    std::cout << "Введите скобочную последовательность:";
    std::cin >> SymbolsPrint;

    std::cout << std::boolalpha << checkBrackets(SymbolsPrint) << std::endl;

    return 0;
}